import {http} from "@/api/index";
import {getTokenUser} from "@/lib/utils/TokenUtil";

const system = {
    login:'/auth/login',
    fastLogin:'/auth/fastLogin',
    logout:'/auth/logout',
    refreshToken:'/auth/refreshToken',
    checkToken:'/auth/checkToken',
    getUserInfo:'/user/info',
    test:'/testApi',
    sendEmailCode:'/mail/getCaptcha',
    getAllStaticData:'/system/getAllStaticData',
    getAccountInfo:'/account/info',
    addBalance:'/account/addBalance'
}

export const login = (params) =>{
    return http.request({
        url:system.login,
        method:'post',
        data:params
    })
}
export const fastLogin = (params) =>{
    return http.request({
        url:system.fastLogin,
        method:'post',
        data:params
    })
}
export const logout = (param) =>{
    return http.request({
        url:system.logout,
        method:'get',
        data:param
    })
}
export const getAllStaticData = () =>{
    return http.request({
        url:system.getAllStaticData,
        method:'get',
    })
}
export const refreshToken = ()=>{
    return http.request({
        url:system.refreshToken,
        method:'get'
    })
}
export const checkToken = ()=>{
    return http.request({
        url:system.checkToken,
        method:'get'
    })
}
export const getUserInfo = ()=>{
    console.log(getTokenUser())
    return http.request({
        url:system.getUserInfo,
        method:'get',
        params:{
            uid:getTokenUser()
        }
    })
}
export const getAccountInfo = ()=>{
    console.log(getTokenUser())
    return http.request({
        url:system.getAccountInfo,
        method:'get',
        params:{
            uid:getTokenUser()
        }
    })
}
export const getSmsCaptcha = (param)=>{
    return http.request({
        url:system.sendEmailCode,
        method:'post',
        data:param
    })
}
export const addBalance = (params) =>{
    return http.request({
        url:system.addBalance,
        method:'post',
        data:params
    })
}
